package utils;

import java.util.Properties;

import javax.mail.Message;
import javax.mail.MessagingException;
import javax.mail.Session;
import javax.mail.Transport;
import javax.mail.internet.AddressException;
import javax.mail.internet.InternetAddress;
import javax.mail.internet.MimeMessage;

public class MailSender {
	 public void sendEmail(String title, String message, String receiver){
		Properties props = new Properties();
		Session session = Session.getDefaultInstance(props, null);

		try {
		    Message msg = new MimeMessage(session);
		    msg.setFrom(new InternetAddress("mounierchasles@gmail.com", "project-aar Admin"));
		    msg.addRecipient(Message.RecipientType.TO,
		     new InternetAddress(receiver, "Mr. User"));
		    msg.setSubject(title);
		    msg.setText(message);
		    Transport.send(msg);

		} catch (AddressException e) {
		    e.printStackTrace();
		} catch (MessagingException e) {
		    e.printStackTrace();
		} catch (Exception e) {
			e.printStackTrace();
		}

	}
}
